import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo1 {
    public static void main(String[] args) {
        Callable<Integer> c = new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                int sum = 0;
                for (int i = 0; i < 5000; i++) {
                    sum++;
                }
                return sum;
            }
        };

        FutureTask<Integer> futureTask = new FutureTask<>(c);

        Thread t = new Thread(futureTask);
        t.start();
    }
}
